package com.bootx.officialAccount.util;

import com.bootx.officialAccount.pojo.BatchGetMaterial;
import com.bootx.util.JsonUtils;
import com.bootx.util.WebUtils;
import com.fasterxml.jackson.core.type.TypeReference;

import java.util.HashMap;
import java.util.Map;

/**
 * @author black
 */
public class FreePublishUtils {

    private static final String accessToken = "96_hhsB-Ers7foEi23NcYGHZpBCaqK3a9c_w17fiLGkUUdTPWQ0scf_16sCDA09csFki4CE92mVS_eBRKFgSChFG94PHbwuWhQpcfP6J--ES_cBsgGPRFcFrydfGFcZSIgAGANGW";

    public static BatchGetMaterial batchgetMaterial(String accessToken, Integer offset, Integer count){
        String url = "https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token="+accessToken;
        Map<String,Object> map = new HashMap<>();
        map.put("offset",offset);
        map.put("count",count);
        String post = WebUtils.postJson(url, JsonUtils.toJson(map),null);
        System.out.println(post);
        return JsonUtils.toObject(post, new TypeReference<BatchGetMaterial>() {});
    }

    public static void main(String[] args) {
        batchgetMaterial(accessToken, 10, 10);
    }
}
